package com.zch.spring_demo;

import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author biscuit
 * @data 2018/01/15
 */
@Configuration
/**能够扫描 servlet/filter/listener*/
@ServletComponentScan
public class MyConfiguration {
    /**创建一个properties配置文件的bean，在项目中，可以直接通过这个bean和字段的set方法注入相应的值*/
    @Bean(name = "base")
    public PropertiesFactoryBean propertiesFactoryBean(){
        PropertiesFactoryBean pr = new PropertiesFactoryBean();
        Resource resource = new ClassPathResource("base.properties");
        pr.setLocations(resource);
        return pr;
    }


}
